package com.csii.mobilebanking.tool;

import java.net.URLEncoder;
import java.util.UUID;
import com.csii.mobilebanking.user.TResponse;

public class JsonService
{

	public static String csVersion = "1.2";

	public static String agentCode = "1000002";
	public static String baseurl = "http://192.168.1.47:7780/mhaowai/";//本地测试localhost
	// public static String baseurl ="http://192.168.1.176:6780/mhaowai/";

	// public static String agentCode = "1008889";
	// public static String baseurl ="http://www.haowai.cn/mhaowai/";

	public static String csServerUrl = baseurl + "requestprocess_requestProcess.action";

	public static String csSessionId = "{FEF874A7-08E9-4314-A56B-E05F5A9E1BEA}";
	public static String csHead = "{\"version\":\"" + csVersion + "\",\"id\":\"" + "{" + UUID.randomUUID().toString()
			+ "}" + "\",\"DeviceID\":\"" + "HpGlobals.DeviceID" + "\",\"method\":\"";

	protected static String BuildSendBody(String method, String param)
	{
		String srcstr = csHead + method + "\",\"params\":{" + param + "}}";
		System.out.println("Class = JsonService.java | 请求数据：" + srcstr);
		try
		{

			srcstr = URLEncoder.encode(srcstr, "GBK");
			srcstr = DES.encryptDES(srcstr, DES.decryptKey);
		} catch (Exception e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return srcstr;
	}

	protected static TResponse getResponse()
	{
		TResponse resp = new TResponse();
		resp.Succed = false;
		resp.ErrorCode = -1;
		resp.Memo = "";
		return resp;
	}

	protected static void JsonException(Exception e, TResponse resp)
	{
		resp.Succed = false;
		resp.ErrorCode = -1;
		resp.Memo = e.toString();
	}

}
